// ---------------------------------------------------------------------
//
// -- dfpq基类包
// -- author £
//
// ---------------------------------------------------------------------
const CommonUtil = require('CommonUtil'),
    CommonInfo = require('CommonInfo'),
    AppInfo = require('AppInfo'),
    GameConfig = require('GameConfig'),
    superClass = require('mybase').BaseMediator,
    modelSuper = require('mybase').BaseModel;

let wgbase = {
    //中介层基类
    BaseWGMediator: cc.Class({
        name: "BaseWGMediator",
        extends: superClass,
        properties: {

        },

        initCtor: function () {
            CommonUtil.mysuper(superClass, this, 'initCtor');
        },

        clearData: function () {
            CommonUtil.mysuper(superClass, this, 'clearData');
        },

        register: function (v) {
            CommonUtil.mysuper(superClass, this, 'register', v);
        },

        onRelease: function () {
            CommonUtil.mysuper(superClass, this, 'onRelease');
        },

        onShow: function () {
            CommonUtil.mysuper(superClass, this, 'onShow');

            if (this.scene.onShow)
                this.scene.onShow();
        },

        onHide: function () {
            CommonUtil.mysuper(superClass, this, 'onHide');
        },

        /** 延迟停止阻塞 */
        delayStopBlock: function (time) {
            CommonUtil.delay(this.scene.node, time,
                this.stopBlock, this);
        },

        /** 执行回调 */
        _handleResponse: function () {
            let response;

            while (!this._block && this._responseQueue.length) {
                response = this._responseQueue.shift();

                if (this[response.name]) {
                    this[response.name](response.data);
                }
            }
        },

        inLoadData: function (value, taskName, info, state) {
            if (state === undefined || state === null)
                state = 0;

            require('MainMediator').main_inLoadData(value, taskName, info, state);
        },

        /** 开始切换至游戏界面 */
        toGameScene: function () {
            if (CommonInfo.sceneState === 1) return;

            CommonInfo.sceneState = 1;
            require('MainMediator').main_toGameScene();
            require('LobbyMediator').onHide();
            GameConfig.gameMediator.onShow();
        },

        /** 开始切换至大厅界面 */
        toLobbyScene: function () {
            CommonInfo.sceneState = 0;
            require('MainMediator').main_toLobbyScene();
            GameConfig.gameMediator.onHide();
            require('LobbyMediator').onShow();
        },

         /** 单局重置 */
         roundReset: function () {
            this.resetData();
            this.model.resetData();
            this.scene.roundReset();
        },

        // -------------------------------------------------------------

        //服务器回调 -----------------------------------------------------------

        // -----------------------------------------------------------------------

    }),

    //模型层基类
    BaseWGModel: cc.Class({
        name: "BaseWGModel",
        extends: modelSuper,
        properties: {

        },
    }),
};

module.exports = wgbase;